using System;
using System.Collections.Generic;
using System.Text;
using ERP.BusinessEntities.Base;
using ERP.DAL.Factory;
using System.Data;
namespace ERP.BusinessEntities
{

	public class ICInvStocksController:BaseBusinessController
	{
		public ICInvStocksController()
		{
			dal = FactoryDal.CreateEndDal("ICInvStocks");
		}

        public ICInvStocksInfo GetObject(int iProductID, int iStockID)
        {
            String strQuery = String.Format(@"SELECT * FROM ICInvStocks 
                                                WHERE AAStatus = 'Alive'
                                                AND FK_ICProducts_ID = {0}
                                                AND FK_ICStocks_ID = {1}", iProductID, iStockID);

            DataSet ds = GetDataset(strQuery);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                return (ICInvStocksInfo)GetObjectFromDataRow(ds.Tables[0].Rows[0]);

            return null;

        }

        public DataSet GetObjects(int iStockID, int iProductID)
        {
            String strQuery = String.Format(@"SELECT * FROM ICInvStocks 
                                                WHERE AAStatus = 'Alive'");

            if(iProductID > 0)
                strQuery += String.Format(@" AND FK_ICProducts_ID = {0}", iProductID);

            if (iStockID > 0)
                strQuery += String.Format(@" AND FK_ICStocks_ID = {0}", iStockID);

            return GetDataset(strQuery);

        }

	}
}
